/**
 * @Title: Project.java 
 * @Description: TODO
 * @author <a href="mailto:psammead@126.com">Psammead</a>
 * @date 2011-7-16 上午09:10:07 
 * @version 1.0
 * Copyright 2011 by Psammead
 */
package com.psammead.dms.project.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.psammead.dms.common.core.bo.AbstractBaseBO;
import com.psammead.dms.system.sercurity.entity.SysUser;

/**
 * @ClassName: Project
 * @Description: TODO
 * @author <a href="mailto:psammead@126.com">psammead</a>
 * @version 1.0
 * @date 2011-7-16
 */
@Entity(name="Project")
@Table(name="tb_pm_project")
public class Project extends AbstractBaseBO implements Serializable{

	/**
	 * @Fields serialVersionUID : TODO
	 */
	private static final long serialVersionUID = 4255103646692928288L;
	private long id;
	private String name;
	private String address;
	private Customer customer;
	private Date createTime;
	private Date submitTime;
	private Date updateTime;
	private Date signTime;
	private SysUser creator;
	private SysUser submiter;
	private SysUser updater;
	private SysUser charger;
	private Date planStartTime;
	private Date planEndTime;
	private Date actStartTime;
	private Date actEndTime;
	private String status;
	private String discription;
	
	private Set<ProjectAttach> attachs=new HashSet<ProjectAttach>();
	private Set<Issue> issues=new HashSet<Issue>();
	
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="project_id")
	@Override
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	@Column(name="project_name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name="project_address")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name="project_customer")
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name="create_time")
	@Temporal(value=TemporalType.DATE)
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name="submit_time")
	@Temporal(value=TemporalType.DATE)
	public Date getSubmitTime() {
		return submitTime;
	}
	
	public void setSubmitTime(Date submitTime) {
		this.submitTime = submitTime;
	}
	@Column(name="update_time")
	@Temporal(value=TemporalType.DATE)
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	@Column(name="sign_time")
	@Temporal(value=TemporalType.DATE)
	public Date getSignTime() {
		return signTime;
	}

	public void setSignTime(Date signTime) {
		this.signTime = signTime;
	}

	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.MERGE,
		CascadeType.REFRESH},optional=true)
	@JoinColumn(name="creator")
	public SysUser getCreator() {
		return creator;
	}

	public void setCreator(SysUser creator) {
		this.creator = creator;
	}

	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.MERGE,
			CascadeType.REFRESH},optional=true)
	@JoinColumn(name="submiter")
	public SysUser getSubmiter() {
		return submiter;
	}

	public void setSubmiter(SysUser submiter) {
		this.submiter = submiter;
	}
	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.MERGE,
			CascadeType.REFRESH},optional=true)
	@JoinColumn(name="updater")
	public SysUser getUpdater() {
		return updater;
	}

	public void setUpdater(SysUser updater) {
		this.updater = updater;
	}

	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.MERGE,
			CascadeType.REFRESH},optional=true)
	@JoinColumn(name="charger")
	public SysUser getCharger() {
		return charger;
	}

	public void setCharger(SysUser charger) {
		this.charger = charger;
	}

	@Column(name="plan_start_time")
	@Temporal(value=TemporalType.DATE)
	public Date getPlanStartTime() {
		return planStartTime;
	}

	public void setPlanStartTime(Date planStartTime) {
		this.planStartTime = planStartTime;
	}

	@Column(name="plan_end_time")
	@Temporal(value=TemporalType.DATE)
	public Date getPlanEndTime() {
		return planEndTime;
	}

	public void setPlanEndTime(Date planEndTime) {
		this.planEndTime = planEndTime;
	}

	@Column(name="act_start_time")
	@Temporal(value=TemporalType.DATE)
	public Date getActStartTime() {
		return actStartTime;
	}

	public void setActStartTime(Date actStartTime) {
		this.actStartTime = actStartTime;
	}

	@Column(name="act_end_time")
	@Temporal(value=TemporalType.DATE)
	public Date getActEndTime() {
		return actEndTime;
	}


	public void setActEndTime(Date actEndTime) {
		this.actEndTime = actEndTime;
	}

	@Column(name="status")
	public String getStatus() {
		return status;
	}


	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name="description",length=1024)
	public String getDiscription() {
		return discription;
	}

	public void setDiscription(String discription) {
		this.discription = discription;
	}

	@OneToMany(mappedBy="project",cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	public Set<ProjectAttach> getAttachs() {
		return attachs;
	}

	public void setAttachs(Set<ProjectAttach> attachs) {
		this.attachs = attachs;
	}
	
	public void addAttach(ProjectAttach attach) {  
        if (!this.attachs.contains(attach)) {  
            this.attachs.add(attach);  
            attach.setProject(this);
        }  
    }  
    public void removeAttach(ProjectAttach attach) {  
    	attach.setProject(null);  
        this.attachs.remove(attach);  
    }

	@OneToMany(mappedBy="project",cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	public Set<Issue> getIssues() {
		return issues;
	}

	public void setIssues(Set<Issue> issues) {
		this.issues = issues;
	}

	public void addIssues(Issue issue) {  
        if (!this.issues.contains(issue)) {  
            this.issues.add(issue);  
            issue.setProject(this);
        }  
    }  
    public void removeIssues(Issue issue) {  
    	issue.setProject(null);  
        this.issues.remove(issue);  
    }
}
